import datetime

from pydantic import BaseModel, Field
from typing import Optional, List


class DeviceModel(BaseModel):
    id: Optional[int] = Field(None, primary_key=True)
    device_id: Optional[str] = Field(None, comment='设备编码')
    device_type: Optional[str] = Field(None, comment='设备类型')
    state: Optional[int] = Field(None, comment='状态（0 失效，1 有效）')
    create_time: Optional[datetime.datetime] = Field(None, comment='创建时间')
    car_device_no: Optional[str] = Field(None, comment='车载设备号')
    online_date: Optional[datetime.datetime] = Field(None, comment='上线日期')
    warranty_period: Optional[datetime.datetime] = Field(None, comment='保修期')
    create_by: Optional[str] = Field(None, comment='创建人')
    update_time: Optional[datetime.datetime] = Field(None, comment='修改时间')
    update_by: Optional[str] = Field(None, comment='修改人')
    # 过保,在保
    warranty_period_desc: Optional[str] = Field(None, comment='过保，在保')

class DeviceForQuery(BaseModel):
    device_id: Optional[str] = Field(None, title="车载设备号/车牌号")
    device_type: Optional[str] = Field(None, title="设备模式")
    warranty_period: Optional[str] = Field(None, title="保修(过保,在保)")

class DevicePageObject(DeviceForQuery):
    page_num: int
    page_size: int

class CrudDeviceResponse(BaseModel):
    is_success: bool
    message: str
